package com.example.cloud.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import lombok.extern.slf4j.Slf4j;

/**
 * 分布式服务跟踪：Sleuth
 *
 * @author tongyufu
 */
@Slf4j
@RestController
public class SleuthAction {

    @Autowired
    private RestTemplate restTemplate;

    /**
     * hello
     *
     * @return hello
     */
    @RequestMapping("sleuthHello")
    public String sleuthHello() {
        String url = "http://HELLO-SERVICE/hello";
        String result = restTemplate.getForEntity(url, String.class).getBody();
        log.info("=======hello1======" + result);

        url = "http://HELLO-SERVICE2/hello";
        result = restTemplate.getForEntity(url, String.class).getBody();
        log.info("=======hello2======:" + result);
        return result;
    }

}
